<template>
  <div>
    <zeda-dialog
      v-model="visible"
      width="50%"
      title="详情"
      :before-close="handleClose"
    >
      <Title slot="green">
        <desc-base-info
          :data="info"
          :colnum-info="colnumInfo"
          align="right"
          :no-line-height="true"
          label-width="120px"
          class="base-info"
        ></desc-base-info>
      </Title>
      <form-button
        slot="footer"
        cancel-text="关闭"
        :show-submit-button="false"
        @cancel="handleClose"
      ></form-button>
    </zeda-dialog>
  </div>
</template>
    <script>
import { detail, add, edit } from "@/api/configuration/energyUnitPrice.js";
import FormButton from "@/components/FormButton";
export default {
  components: {
    FormButton,
  },
  props: {
    visible: { type: Boolean, default: false },
    id: { type: [String, Number], default: "" },
  },
  data() {
    return {
      info: {},
      show: false,
    };
  },
  computed: {
    colnumInfo({ info }) {
      return [
        { label: "适用区域", prop: "deptName", colNum: 2 },
        { label: "适用周期", prop: "effectivePeriod", colNum: 2 },
        {
          label: "电消费量",
          prop: "electricityConsumptionUnitPrice",
          colNum: 2,
          unit: "元/千瓦时",
        },
        {
          label: "水消费量",
          prop: "waterConsumptionUnitPrice",
          colNum: 2,
          unit: "元/立方米",
        },
        {
          label: "煤炭消费量",
          prop: "coalConsumptionUnitPrice",
          colNum: 2,
          unit: "元/吨",
        },
        {
          label: "天燃气消费量",
          prop: "naturalGasConsumptionUnitPrice",
          colNum: 2,
          unit: "元/立方米",
        },
        {
          label: "再生能源消费量",
          prop: "renewableEnergyConsumptionUnitPrice",
          colNum: 2,
          unit: "元/千卡",
        },
        {
          label: "绿电消费量",
          prop: "greenElectricityConsumptionUnitPrice",
          colNum: 2,
          unit: "元/千伏安月",
        },
        {
          label: "碳汇消费量",
          prop: "carbonOffsetConsumptionUnitPrice",
          colNum: 2,
          unit: "元/吨",
        },
        {
          label: "汽油消费量",
          prop: "gasolineConsumptionUnitPrice",
          colNum: 2,
          unit: "元/升",
        },
        {
          label: "柴油消费量",
          prop: "vehicleDieselFuelUnitPrice",
          colNum: 2,
          unit: "元/升",
        },
        {
          label: "液化石油消费量",
          prop: "liquefiedPetroleumGasConsumptionUnitPrice",
          colNum: 2,
          unit: "元/千克",
        },
        {
          label: "热力消费量",
          prop: "heatConsumptionUnitPrice",
          colNum: 2,
          unit: "元/吉焦",
        },
        {
          label: "其他能源消费量",
          prop: "otherEnergyUnitPrice",
          colNum: 2,
          unit: "元/吨标准煤",
        },
      ];
    },
  },
  watch: {
    visible(value) {
      if (value) {
        this.getInfo();
      }
    },
  },
  methods: {
    getInfo() {
      detail(this.id)
        .then((res) => {
          if (res.code === 700) {
            this.$message.warning(res.msg);
            return false;
          }
          this.info = res.data;
        })
        .catch(() => {
          // this.$message.error("系统错误,请联系管理员!错误码306004");
        });
    },
    handleClose(status) {
      this.$emit("close", typeof status === "boolean" ? status : false);
    },
  },
};
</script>
    